<?php
		function  get_tour_price_table_excel_file()
		{
				//$upload = wp_upload_dir();		
				global $post,$wpdb;
				
				$attachment_id = get_post_meta(get_the_ID(),$wpdb->prefix.'price_table',true);				
				$filename = get_attached_file($attachment_id);
				
				//$filename = get_option("file_price_table");
				//$filename = $upload['basedir'].$filename;		
				//echo $filename;		
				$wp_filetype = wp_check_filetype(basename($filename), null );								
				if(file_exists($filename) && $wp_filetype['ext']=='xls')
				{
					return $filename;
				}			
		}

		$filename =get_tour_price_table_excel_file();
		
		
		if($filename) 
		{		
			require_once (TEMPLATEPATH . '/IOs/excel_reader.php' );	
			error_reporting(E_ALL ^ E_NOTICE);
			$data = new Spreadsheet_Excel_Reader($filename); 
			//echo $data->dump();
			$rowsnum = $data->rowcount($sheet_index=0);
			$colnum	 = $data->colcount($sheet_index=0);
			//print_r($data);
			$html=null;
			$html.= '<table width="97%" align="center" cellspacing="0" cellpadding="0"> <tbody>';
			$step=1;
			for($i=1;$i<=$colnum;$i++)
			{
				if($step==1)
					$html.= '<tr class="tieude">';
				else 
					$html.= '<tr>';
				$tep=1;
				for($j=1;$j<=$colnum;$j++)
				{
					if($step==1)
					{
						if($tep==1)
							$html.= '<td class="cot1">'.$data->val($i, $j).'</td>';
						else if($tep==5)
							$html.= '<td class="cot5">'.$data->val($i, $j).'</td>';
						else 
							$html.= '<td>'.$data->val($i, $j).'</td>';
					}
					else 
					{
						if($tep==1)
							$html.= '<td class="cot1">'.$data->val($i, $j).'</td>';
						else if($tep==5)
							$html.= '<td class="cot5">'.$data->val($i, $j).' USD</td>';
						else 
							$html.= '<td>'.$data->val($i, $j).'</td>';
					}		
					$tep++;					
				}	
				$html.= '</tr>';
				$step++;			
			}			
			$html.= '</tbody></table>';	
			echo $html;			
		}
		else 
		{
			echo 'Not update Price table';
		}
?>